package io.renren.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import io.renren.entity.SysProductSkuEntity;
import io.renren.service.SysProductSkuService;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 *
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2021-01-07 15:45:18
 */
@RestController
@RequestMapping("sys/sysproductsku")
public class SysProductSkuController {
    @Autowired
    private SysProductSkuService sysProductSkuService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @ApiOperation("列表")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sysProductSkuService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @ApiOperation("根据id查询详情")
    public R info(@PathVariable("id") Integer id){
        SysProductSkuEntity sysProductSku = sysProductSkuService.getById(id);

        return R.ok().put("sysProductSku", sysProductSku);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation("添加")
    public R save(@RequestBody SysProductSkuEntity sysProductSku){
        sysProductSkuService.save(sysProductSku);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation("修改")
    public R update(@RequestBody SysProductSkuEntity sysProductSku){
        ValidatorUtils.validateEntity(sysProductSku);
        sysProductSkuService.updateById(sysProductSku);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    @ApiOperation("删除")
    public R delete(@RequestBody Integer[] ids){
        sysProductSkuService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }



}
